package com.jic.interaction.JDVOP.controller;

import com.jic.interaction.JDVOP.common.utils.RestResult;
import com.jic.interaction.JDVOP.model.vo.request.*;
import com.jic.interaction.JDVOP.model.vo.response.InvoiceItemResponse;
import com.jic.interaction.JDVOP.model.vo.response.InvoiceLogisticsResponse;
import com.jic.interaction.JDVOP.model.vo.response.InvoiceWaybillNumberResponse;
import com.jic.interaction.JDVOP.service.InvoiceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * @Auther YGH
 * @DATE 2020/11/16/17:41
 */
@RestController
@RequestMapping("api/invoice/")
@Api(value = "【发票API】", tags = "【发票API】", description = "InvoiceController")
public class InvoiceController {

    @Resource
    private InvoiceService invoiceService;

    @PostMapping("applyInvoice")
    @ApiOperation("申请开票")
    public RestResult applyInvoice(@RequestBody InvoiceApplyRequest invoiceApplyRequest) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        return invoiceService.applyInvoice(invoiceApplyRequest);
    }

    @PostMapping("selInvoiceByOrderId")
    @ApiOperation("查询发票第三方申请单号实例")
    public RestResult selInvoiceByOrderId(@RequestBody InvoiceByOrderIdRequest invoiceByOrderIdRequest) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        return invoiceService.selInvoiceByOrderId(invoiceByOrderIdRequest);
    }

    @PostMapping("selInvoiceOutline")
    @ApiOperation("查询发票概要")
    public RestResult selInvoiceOutline(@RequestBody InvoiceOutlineRequest invoiceOutlineRequest) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        return invoiceService.selInvoiceOutline(invoiceOutlineRequest);
    }

    @PostMapping("selInvoiceByIdorCodeList")
    @ApiOperation("查询发票明细")
    public RestResult<InvoiceItemResponse> selInvoiceByIdorCodeList(@RequestBody InvoiceDetailedRequest invoiceDetailedRequest) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        return invoiceService.selInvoiceByIdorCodeList(invoiceDetailedRequest);
    }

    @PostMapping("selElectronicsInvoiceByIdorType")
    @ApiOperation("查询电子发票明细")
    public RestResult<List<T>> selElectronicsInvoiceByIdorType(@RequestBody InvoiceElectronicsDetailedRequest invoiceElectronicsDetailedRequest) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        return invoiceService.selElectronicsInvoiceByIdorType(invoiceElectronicsDetailedRequest);
    }

    @PostMapping("selInvoiceByMarkIdList")
    @ApiOperation("查询电子发票运单号")
    public RestResult<List<InvoiceWaybillNumberResponse>> selInvoiceByMarkIdList(@RequestBody InvoiceOutlineRequest invoiceOutlineRequest) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        return invoiceService.selInvoiceByMarkIdList(invoiceOutlineRequest);
    }

    @PostMapping("selInvoiceByJdOrderIdList")
    @ApiOperation("查询电子发票物流信息")
    public RestResult<List<InvoiceLogisticsResponse>> selInvoiceByJdOrderIdList(@RequestBody InvoiceByOrderIdRequest invoiceByOrderIdRequest) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        return invoiceService.selInvoiceByJdOrderIdList(invoiceByOrderIdRequest);
    }

    @PostMapping("CancelInvoice")
    @ApiOperation("取消发票申请")
    public RestResult<Boolean> CancelInvoice(@RequestBody InvoiceOutlineRequest invoiceOutlineRequest) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        return invoiceService.CancelInvoice(invoiceOutlineRequest);
    }

}
